A Modal Calculus for Exception Handling
نویسنده
چکیده
The exception monad, while an adequate mechanism for providing the denotational semantics of exceptions, is somewhat awkward to program with. Just as any other monad, it forces a programming style in which exceptional computations are explicitly sequentialized in the program text. In addition, values of computation types must usually be tested before use, in order to determine if they correspond to a raised exception. In this paper we propose a type system that rearranges the monadic formulation, so that the above shortcomings are avoided. Instead of the exception monad, we propose the operator from the modal logic S4 to encode exceptional computation. The way tracking of exceptions is organized in the modal system is exactly dual to the monadic case, reflecting the well-known property that is actually a comonad.
منابع مشابه
A modal calculus for effect handling
In their purest formulation, monads are used in functional programming for two purposes: (1) to hygienically propagate effects, and (2) to globalize the effect scope – once an effect occurs, the purity of the surrounding computation cannot be restored. As a consequence, monadic typing does not provide very naturally for the practically important ability to handle effects, and there is a number ...
متن کاملA Simple Calculus of Exception Handling
We introduce a simply-typed λ-calculus (λexn) featuring an ML-like exception handling mechanism. This calculus, whose type system corresponds to classical logic through the Curry-Howard isomorphism, satifies several interesting properties: among other, Church-Rosser, subject reduction, and strong-normalisation. Moreover, its typing system ensures that the reduction of well-typed expressions can...
متن کاملDisjunctive Normal Forms specify Multi-Exception Handlers
Within a classical call-by-name λ -calculus, we prove, using Krivine’s realizability, that all terms typable with disjunctive normal forms (disjunctions of conjunctions of literals) share a common computational behaviour: they implement a multi-exception handling mechanism whose exact geometry depends on the tautology. By using dynamic binding, we are able to define equivalent and more efficien...
متن کاملCategorical and Kripke Semantics for Constructive Modal Logics
We consider two systems of constructive modal logic which are computationally motivated. Their modalities admit several computational interpretations and are used to capture intensional features such as notions of computation, constraints, concurrency design, etc. Both systems have so far been studied mainly from a type-theoretic and category-theoretic perspectives, but Kripke models for simila...
متن کاملModel Checking Java Using Pushdown Systems
In recent years, model checking algorithms for the verification of infinite-state systems were introduced. We evaluate the possibility of using the algorithms for pushdown systems and various modal logics of [3] for verification of Java programs. It turns out that pushdown systems are particularly suitable for modeling the control flow of sequential Java programs, including exceptions (which ar...
متن کامل